package reader;

import java.io.File;
import java.io.FileFilter;

public class ReadingMachine {
	
	public final static String jpeg = "jpeg";
    public final static String jpg = "jpg";
    public final static String gif = "gif";
    public final static String tiff = "tiff";
    public final static String tif = "tif";
    public final static String png = "png";
    private final static String newline = "\n";
    
    
	public boolean searchFiles(final Folderlocator flocobj){
		
	    System.out.println("in the reading machine....");
	    FileFilter ext_filter = new FileFilter() {			
			@Override
			public boolean accept(File f) {
				int i = f.getName().lastIndexOf('.');
				String str = f.getName().substring(i);
				if(flocobj.getSearch_criteria().equalsIgnoreCase(str)){
					return true;
				}
				return false;
			}
		};
		
	    System.out.println("reading files now....");
	    File folder = new File(flocobj.getSearch_folder());
	    
	    //File files[] = folder.listFiles();
	    File files[] = folder.listFiles(ext_filter);
	    
	    for (File f : files){
	    	
	    	flocobj.Notification.append(f.getName()+ newline);
	    }
	       
	    
		return false;
	}
	
}
